home *** CD-ROM | disk | FTP | other *** search
- Path: crchh327.rich.bnr.ca!jobell
- From: jobell@bnr.ca (Bret Bieghler)
- Newsgroups: comp.lang.c++
- Subject: Fishing for Opinions: Global Variables in GUI
- Date: 5 Jan 1996 15:31:56 GMT
- Organization: Bell-Northern Research Ltd.
- Message-ID: <4cjg9c$m92@crchh327.rich.bnr.ca>
- NNTP-Posting-Host: crchh524.rich.bnr.ca
-
- Hi.
-
- I'm writing a GUI shell to one of our automated systems and have
- come across a slight problem.
-
- Many people think that global variables are the children of Satan,
- but here is a case where I'm not sure what to do.
-
- I have an array which contains the status of certain items, yet there
- are different ways in the GUI to change their statuses. So I'd just
- like to declare the array globally and allow each callback function
- to manipulate it as they see fit. Is there a way, in C++, to create
- a variable that is "global" but only to select functions, since there
- are only about three functions that are manipulating this array.
-
- Here's what I've done so far:
-
- // a bunch of function declarations and definitions:
-
- // and then:
-
- LIU7 LIU7Array[MAX_LIU7S];
- int currentItem;
-
- void foobar (callback structs)
- {
- // code manipulates LIU7Array
- }
-
- void moobar (callback structs)
- {
- // code manipulates LIU7Array
- }
-
- // etc.
-
- This way I declare the array globally only at the point where the functions
- which will access them begin.
-
- I tried:
-
- // bunch of functions
-
- {
- LIU7 LIU7Array[
-
- // code
- }
-
- and tried to brace them like a scope but that doesn't work.
-
- Any suggestions?
-
- E-mail preferred.
-
- Thanks,
-
- Joe
- --
- Joseph A. Bell (NOT Bret Bieghler) jobell@bnr.ca
- Northern Telecom / Bell-Northern Research
- "What? Evacuate now, in our moment of triumph? Surely you overestimate their chances."
-